<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Insert title here</title>
	</head>

	<e:View id="view">
	    <script type="text/javascript">SkinUtil.getSkin();</script>
	    <script type="text/javascript">SkinUtil.getModuleSkin();</script>
    
		<div id="Invisual Controls" style="min-height: 40px; background-color: LemonChiffon;" >
			<e:Dataset id="Dataset_CodeType" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_CodeType" pageSize="-1" readOnly="true" onAfterScroll="Dataset_CodeType_onAfterScroll(dataset)">
				<e:Field name="codeTypeId" dataType="string" label="代码类别ID" maxLength="32" required="true" />
				<e:Field name="codeTypeName" dataType="string" label="代码类别名称" maxLength="100" required="true" />
				<e:Field name="sortNo" dataType="integer" label="排序号" maxLength="10" required="true" />
				<e:Field name="remark" dataType="string" label="备注" maxLength="400" />
			</e:Dataset>
			<e:Dataset id="Dataset_CodeInfo" datasetDefinition="DatasetDefinition_sys.dsd" datasetRef="Dataset_CodeInfo" pageSize="15" loadDataCommand="Command_Load">
				<e:Field name="codeInfoId" dataType="string" label="代码信息ID" maxLength="32" visible="false" />
				<e:Field name="codeTypeId" dataType="string" label="代码类别ID" maxLength="32" readOnly="true" />
				<e:Field name="value" dataType="string" label="下拉框值" maxLength="100" required="true" />
				<e:Field name="content" dataType="string" label="下拉框显示" maxLength="100" required="true" />
				<e:Field name="minValue" dataType="integer" label="区间最小值" maxLength="10" />
				<e:Field name="maxValue" dataType="integer" label="区间最大值" maxLength="10" />
				<e:Field name="sortNo" dataType="integer" label="排序号" maxLength="10" required="true" />
				<e:Field name="remark" dataType="string" label="备注" maxLength="400" />
			</e:Dataset>

			<e:Command id="Command_Save" action="com.longtop.framework.sys.codeInfo.web.CodeInfoListAction" method="saveCodeInfo"  onExecuteSuccess="Button_Search_onClick()">
				<e:DatasetInfo name="DatasetInfo1" dataset="Dataset_CodeInfo" alwayRefreshClient="false" submitType="changes"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Search" action="com.longtop.framework.sys.codeInfo.web.CodeInfoListAction" method="searchCodeInfo" submitForm="true"  showHintInfoOnSuccess="false"  onBeforeExecute="Command_Search_onBeforeExecute(command)">
				<e:DatasetInfo name="DatasetInfo2" dataset="Dataset_CodeInfo" alwayRefreshClient="true" submitType="all"></e:DatasetInfo>
			</e:Command>
			<e:Command id="Command_Load" action="com.longtop.framework.sys.codeInfo.web.CodeInfoListAction" method="loadCodeInfo"  submitForm="true" showHintInfoOnSuccess="false"  onBeforeExecute="Command_Search_onBeforeExecute(command)">
				<e:DatasetInfo name="DatasetInfo3" dataset="Dataset_CodeInfo" alwayRefreshClient="true"></e:DatasetInfo>
			</e:Command>
		</div>

		<body>
			<e:Page id="ePage" action="com.longtop.framework.sys.codeInfo.web.CodeInfoListAction" style="min-height: 80px; width: 100%; height: 100%;" onAfterLoadPage="ePage_onAfterLoadPage()">
				<table style="width: 100%; height: 100%;" border="0" cellpadding="0" cellspacing="0" >
					<tr>
						<td align="left" valign="top">
							<e:Panel id="Panel_CodeType" style="width: 285px; height: 100%" caption="选择代码类别" captionIcon="/images/query_win.gif" captionStyle="color:#888888" allowFold="true" showArrowButton="false">
								<table style="text-align: left; width: 100%;" border="0" cellpadding="3" cellspacing="3" width="100%" align="center">
									<tr>
										<td>
											<e:Grid id="Grid_CodeType" style="width:100%; height:490px;" dataset="Dataset_CodeType" showIndicator="false" allowDragColumn="false">
											<e:Column name="codeTypeId"  field="codeTypeId" dataType="string" style="width: 50%"></e:Column>
											<e:Column name="codeTypeName"  field="codeTypeName" dataType="string" style="width: 44%"></e:Column>
											</e:Grid>
										</td>
									</tr>
								</table>
							</e:Panel>
						</td>
						<td width="100%" align="top">
							<e:Panel id="Panel_Result" style="width: 100%; height: 100%" captionStyle="color:#888888" caption="查询结果列表" captionIcon="/images/list_win.gif" showArrowButton="false">
								<table style="width: 100%;" border="0" cellpadding="3" cellspacing="3" >
									<tr>
										<td>
											<table style=" width: 100%;" border="0" cellpadding="1" cellspacing="1">
												<tr>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_CodeTypeName" caption="代码类别名称:"></e:Label>
													</td>
													<td align="left">
														<e:Text id="Text_CodeTypeName" style="width:180px;" readOnly="true"></e:Text>&nbsp;&nbsp;
														<e:Text id="Text_CodeTypeId" style="display:none; width:0px" ></e:Text> 
													</td>
													<td align="right" nowrap="nowrap">
														<e:Label id="Label_CodeTypeValue" caption="代码值:"></e:Label>
													</td>														
													<td align="left">
														<e:Text id="Text_CodeInfoValue" style="width: 120px;"></e:Text>&nbsp;&nbsp;
													</td>
													<td  align="left" width="20%">	
														<e:Button id="Button_Search" style="height: 22px; width: 70px" caption="查询" icon="/images/query.gif" onClick="Button_Search_onClick()" command="Command_Search"></e:Button>
													</td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
												<tr>
													<td height="27px" width="1%">
														<e:RecordNavigator id="RecordNavigator_CodeInfo" dataset="Dataset_CodeInfo" showNavigatorButton="false">
															<e:RecordButton id="RecordButton_insert" label="新增" onClick="RecordButton_add_onClick()" icon="/images/add.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_delete" label="删除" onClick="deleteRecord" icon="/images/delete.gif"></e:RecordButton>
															<e:RecordButton id="RecordButton_save" label="保存" icon="/images/submit.gif" onClick="RecordButton_save_onClick()"></e:RecordButton>
														</e:RecordNavigator>
													</td>
													<td align="left" width="99%"><e:PageNavigator id="PageNavigator_CodeInfo" dataset="Dataset_CodeInfo" showRecordNum="true"></e:PageNavigator></td>
												</tr>
											</table>
										</td>
									</tr>
									<tr>
										<td>
											<e:Grid id="Grid_CodeInfo" style="width: 100%; height: 423px;" showIndex="true" dataset="Dataset_CodeInfo">
											</e:Grid>
										</td>
									</tr>
								</table>
							</e:Panel>
						</td>
					</tr>
			    </table>
			</e:Page>
		</body>
	</e:View>
</html>	

<script type="text/javascript">
	var allowSearch = false;

	//init
	function ePage_onAfterLoadPage(){
		allowSearch = true;
		Dataset_CodeType.onAfterScroll();
	}
	
	//查询
	function Button_Search_onClick(){
	    Command_Search.execute();
	}
	
	//保存
	function RecordButton_save_onClick(){
	    Command_Save.execute();
	}
	
	//查询之前
	function Command_Search_onBeforeExecute(command){
	
	}
	
	//新增
	function RecordButton_add_onClick(){
		//codeInfo插入1条记录
		var codeInfoDataset = $J("Dataset_CodeInfo");
		var codeInfoRecord = codeInfoDataset.insertRecord();
		
		//取选中的codeTpye记录
	    var codeTypeRecord = $J("Dataset_CodeType").getCurrentRecord();
	    var codeTypeId = codeTypeRecord.getValue("codeTypeId");
		if(codeInfoRecord == null){
			return;
		}
		codeInfoRecord.setValue("codeTypeId", codeTypeId);	//记录的codeTypeId字段 赋值
	}
	
	//数据集当前记录变化后
	function Dataset_CodeType_onAfterScroll(dataset){
		if (!dataset || !allowSearch) 
			return;
			
	    //取选中的codeTpye记录
	    var codeTypeRecord = $J("Dataset_CodeType").getCurrentRecord();
	    var codeTypeId = codeTypeRecord.getValue("codeTypeId");
	    var codeTypeName = codeTypeRecord.getValue("codeTypeName");
	    
	    //设值,查询codeInfo要用
	    $J("Text_CodeTypeId").setValue(codeTypeId);
	    $J("Text_CodeTypeName").setValue(codeTypeName);
	    		
		Button_Search_onClick();
	}
</script>